home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / PixelizeRegion.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-08-22  |  2.2 KB  |  90 lines

  1. /* Image Engineer ARexx macro script
  2. ** by Simon Edwards
  3. ** 27/4/95
  4. ** Improved by Patrik M Nydensten 
  5. ** 22/8 1996 Stockholm/Sweden
  6. */
  7. /* Pixelizes the region marked out on a given project
  8. ** or the entire image if no box is selected.
  9. */
  10.  
  11. Options results
  12.  
  13. if arg()==0 then exit
  14.  
  15. 'PROJECT_INFO' arg(1) 'BOX'    /* Get the dimensions of the box */
  16. CropBox=RESULT
  17.  
  18. signal on error            /* Setup a place for errors to go */
  19.  
  20. if CropBox ~= 'RESULT' then do
  21.   'CROP' arg(1) CropBox        /* Crop it */
  22.   CropPic=RESULT
  23.  
  24.   'PROJECT_INFO' CropPic 'WIDTH'    /* Get width of cropped image */
  25.   CropWidth=RESULT
  26.   'PROJECT_INFO' CropPic 'HEIGHT'    /* Get height of cropped image */
  27.   CropHeight=RESULT
  28.  
  29.   nil = get_number()
  30.  
  31.   'SCALE' CropPic trunc(CropWidth/PX) trunc(CropHeight/PY) 'FAST'
  32.   LittleCrop=RESULT
  33.   CLOSE CropPic
  34.  
  35.   'SCALE' LittleCrop CropWidth CropHeight 'FAST'
  36.   PixCrop=RESULT
  37.   CLOSE LittleCrop
  38.  
  39.   'MARK' PixCrop 'PRIMARY'
  40.   'MARK' arg(1) 'SECONDARY'
  41.   'COMPOSITE' WORD(CropBox,1) WORD(CropBox,2) MIX 100
  42.  
  43.   CLOSE PixCrop
  44. end
  45. else do
  46.   'PROJECT_INFO' arg(1) 'WIDTH'    /* Get width of image */
  47.   CropWidth=RESULT
  48.   'PROJECT_INFO' arg(1) 'HEIGHT'    /* Get height of image */
  49.   CropHeight=RESULT
  50.  
  51.   nil = get_number()
  52.  
  53.   'SCALE' arg(1) trunc(CropWidth/PX) trunc(CropHeight/PY) 'FAST'
  54.   LittleCrop=RESULT
  55.  
  56.   'SCALE' LittleCrop CropWidth CropHeight 'FAST'
  57.   PixCrop=RESULT
  58.   CLOSE LittleCrop
  59. end
  60.  
  61. exit
  62.  
  63. get_number:
  64.   'GET_NUMBER "Pixelize X (width) amount." 2' trunc(CropWidth/8) '"  OK  " 4' 'SLIDER'
  65.   if RC=5 then exit
  66.   PX = RESULT
  67.  
  68.   'GET_NUMBER "Pixelize Y (height) amount." 2' trunc(CropHeight/8) '"  Go!  "' PX 'SLIDER'
  69.   if RC=5 then exit
  70.   PY = RESULT
  71. return ''
  72.  
  73. /*******************************************************************/
  74. /* This is where control goes when an error code is returned by IE */
  75. /* It puts up a message saying what happened and on which line     */
  76. /*******************************************************************/
  77. error:
  78. if RC=5 then do            /* Did the user just cancel us? */
  79.     IE_TO_FRONT
  80.     LAST_ERROR
  81.     'REQUEST "'||RESULT||'"'
  82.     exit
  83. end
  84. else do
  85.     IE_TO_FRONT
  86.     LAST_ERROR
  87.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  88.     exit
  89. end
  90.